{include file="common/_header"}

<body>

<div class="x-body layui-anim layui-anim-up">
    <form class="layui-form">
        <input type="hidden" name="stock_id" value="{$data.stock_id}">
        <input type="hidden" name="product_id" value="{$data.product_id}">

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">规格名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="stock_name" autocomplete="off" class="layui-input" lay-verify="required"
                           value="{$stock.p_s_name}">
                </div>
            </div>
        </div>
        {if $data.is_show == true}
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">团餐详情</label>
                <div class="layui-input-inline" style="width: 80%;">

                        <textarea class="layui-textarea" placeholder="请输内容"
                                  name="g_m_details" lay-verify="content"
                                  id="lay_edit2" style="border: 2px;">{$stock.g_m_details}</textarea>

                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">团餐简述</label>
                <div class="layui-input-inline">
                    <input type="text" name="g_m_paper" autocomplete="off" class="layui-input" lay-verify="required"
                           value="{$stock.g_m_paper}">
                </div>
            </div>
        </div>
        {/if}
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">库存数量</label>
                <div class="layui-input-inline">
                    <input type="text" name="stock_number" autocomplete="off" class="layui-input" value="{$stock.stock}">
                </div>
            </div>
        </div>

        <div style="margin-top: 50px; margin-right: 50px;text-align: center;">
            <button type="button" lay-submit lay-filter="add" class="layui-btn">立即提交</button>
        </div>
    </form>
</div>
</body>
<script>
    layui.use('form', function(){
        var form = layui.form;


        form.on('submit(add)', function (data) {
            $.ajax({
                'url': 'boxestock',
                'type': 'post',
                'data': data.field,
                'dataType': 'json',
                success: function (data) {
                    if(data.code == 1){
                        layer.msg(data.msg, {
                            icon: 6,
                            time: 800,
                        },function () {
                            window.parent.location.reload();
                        })
                    } else {
                        layer.msg(data.msg, {
                            icon: 5,
                            time: 800,
                        })
                    }
                }
            });
        })
    });

</script>


<script>

    layui.use(['form', 'layer', 'layedit', 'upload'], function () {

        var form = layui.form;
        var layedit = layui.layedit;
        var up_url = "{:url('/main/ueditor')}";


        layedit.set({
            //暴露layupload参数设置接口 --详细查看layupload参数说明
            uploadImage: {
                url: up_url //接口url
                , type: 'post' //默认post
                , accept: 'image'
                , acceptMime: 'image/*'
                , exts: 'jpg|png|gif|bmp|jpeg'
            }
            , devmode: true
            //插入代码设置
            , codeConfig: {
                hide: true,  //是否显示编码语言选择框
                default: 'javascript' //hide为true时的默认语言格式
            }
            , tool: [
                'strong' //加粗
                , 'italic' //斜体
                , 'underline' //下划线
                , 'del' //删除线

                , '|' //分割线

                , 'left' //左对齐
                , 'center' //居中对齐
                , 'right' //右对齐

            ]
            , height: 300, //设置编辑器高度
        });

        var index = layedit.build('lay_edit2', {
            width: 200,
            height: 300, //设置编辑器高度
        });   //建立编辑器

        //提交时把值同步到文本域中
        form.verify({
            //content富文本域中的lay-verify值
            content: function (value) {
                return layedit.sync(index);
            }
        });

    });


</script>

{include file="common/_bottom"}